_loadApps: function() {
let apps = Gio.AppInfo.get_all().filter(function(appInfo) {
+ try {
+ let id = appInfo.get_id(); // catch invalid file encodings
+ } catch(e) {
+ return false;
+ }
return appInfo.should_show();
}).map(function(app) {
return app.get_id();
getInitialResultSet: function(terms, callback, cancellable) {
let query = terms.join(' ');
- let groups = Gio.DesktopAppInfo.search(query);
+ let groups = Shell.AppSystem.search(query);
let usage = Shell.AppUsage.get_default();
let results = [];
groups.forEach(function(group) {
if (!_listsIntersect(folderCategories, appCategories))
return;
- addAppId(appInfo.get_id());
+ try {
+ addAppId(appInfo.get_id()); // catch invalid file encodings
+ } catch(e) {
+ }
});
this.actor.visible = this.view.getAllItems().length > 0;
return ret;
}
+
+/**
+ * shell_app_system_search:
+ * @search_string: the search string to use
+ *
+ * Wrapper around g_desktop_app_info_search() that replaces results that
+ * don't validate as UTF-8 with the empty string.
+ *
+ * Returns: (array zero-terminated=1) (element-type GStrv) (transfer full): a
+ * list of strvs. Free each item with g_strfreev() and free the outer
+ * list with g_free().
+ */
+char ***
+shell_app_system_search (const char *search_string)
+{
+ char ***results = g_desktop_app_info_search (search_string);
+
+ for (char ***groups = results; *groups; groups++)
+ for (char **ids = *groups; *ids; ids++)
+ if (!g_utf8_validate (*ids, -1, NULL))
+ **ids = '\0';
+
+ return results;
+}
const char *wmclass);
GSList *shell_app_system_get_running (ShellAppSystem *self);
+char ***shell_app_system_search (const char *search_string);
#endif /* __SHELL_APP_SYSTEM_H__ */